package com.doublethread.easymart.common.exception;

import com.doublethread.easymart.common.result.ResultCode;

/**
 * 用户模块异常工具类
 */
public class UserException {

    /**
     * 用户不存在异常
     */
    public static void userNotFound() {
        throw new BusinessException(ResultCode.USER_NOT_FOUND);
    }

    /**
     * 用户已被禁用异常
     */
    public static void userDisabled() {
        throw new BusinessException(ResultCode.USER_DISABLED);
    }

    /**
     * 用户名或密码错误异常
     */
    public static void invalidCredentials() {
        throw new BusinessException(ResultCode.INVALID_USERNAME_OR_PASSWORD);
    }

    /**
     * 用户名已存在异常
     */
    public static void usernameExists() {
        throw new BusinessException(ResultCode.USERNAME_EXISTS);
    }

    /**
     * 邮箱已存在异常
     */
    public static void emailExists() {
        throw new BusinessException(ResultCode.EMAIL_EXISTS);
    }

    /**
     * 手机号已存在异常
     */
    public static void phoneExists() {
        throw new BusinessException(ResultCode.PHONE_EXISTS);
    }

    /**
     * 用户已被删除异常
     */
    public static void userDeleted() {
        throw new BusinessException(ResultCode.USER_DELETED);
    }

    /**
     * Token过期异常
     */
    public static void tokenExpired() {
        throw new BusinessException(ResultCode.TOKEN_EXPIRED);
    }

    /**
     * Token无效异常
     */
    public static void tokenInvalid() {
        throw new BusinessException(ResultCode.TOKEN_INVALID);
    }

    /**
     * 密码不匹配异常
     */
    public static void passwordMismatch() {
        throw new BusinessException(ResultCode.INVALID_USERNAME_OR_PASSWORD);
    }

    /**
     * 密码错误异常
     */
    public static void passwordIncorrect() {
        throw new BusinessException(ResultCode.INVALID_USERNAME_OR_PASSWORD);
    }


}